import request from '@/utils/request'
const dynamicConfigApi = {
  getDynamicConfigList: '/heimdallrApi/dynamicConfig/page',
  addDynamicConfig: '/heimdallrApi/dynamicConfig/add',
  updateDynamicConfig: '/heimdallrApi/dynamicConfig/update',
  deleteDynamicConfig: '/heimdallrApi/dynamicConfig/delete',
}

/**
 * 获取动态配置列表
 * @param {Object} params - 查询参数
 * @returns {Promise} - 包含动态配置列表的Promise对象
 */
export const getDynamicConfigList = (params) => {
  return request({
    url: dynamicConfigApi.getDynamicConfigList,
    method: 'get',
    params,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
  })
}

/**
 * 添加动态配置
 * @param {Object} data - 动态配置数据
 * @returns {Promise} - 包含添加结果的Promise对象
 */
export const addDynamicConfig = (data) => {
  return request({
    url: dynamicConfigApi.addDynamicConfig,
    method: 'post',
    data,
    formData: true,
  })
}

/**
 * 更新动态配置
 * @param {Object} data - 动态配置数据
 * @returns {Promise} - 包含更新结果的Promise对象
 */
export const updateDynamicConfig = (data) => {
  return request({
    url: dynamicConfigApi.updateDynamicConfig,
    method: 'post',
    data,
    formData: true,
  })
}

/**
 * 删除动态配置
 * @param {Object} params - 删除参数
 * @returns {Promise} - 包含删除结果的Promise对象
 */
export const deleteDynamicConfig = (params) => {
  return request({
    url: dynamicConfigApi.deleteDynamicConfig,
    method: 'post',
    data: params,
    formData: true,
  })
}
